GBML manual / Sets

set_length

How many distinct values target currently holds - 0 for an empty set, up to target's own declared capacity once it is full.

Syntax

set_length(target) -> int

Arguments

NameType
targetset

Returns

int

Description

How many distinct values target currently holds - 0 for an empty set, up to target's own declared capacity (/// @capacity, always a power of two - see set_add) once it is full.

Example

/// @type {set<int>}
var visited = [];
set_add(visited, 5);
set_add(visited, 6);
var count = set_length(visited); // 2
A real capture - an empty set, set_length reading 0A real capture - an empty set, set_length reading 0
A real capture - an empty set, set_length reading 0
The same set after two set_add calls - 5 and 6 both members, set_length now 2The same set after two set_add calls - 5 and 6 both members, set_length now 2
The same set after two setadd calls - 5 and 6 both members, setlength now 2

On the GBA

Just the hash set's size() - O(1).

See also: set_addset_removeset_clearset_hasData containers